package org.min.quartz;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


/**
 * 定时任务
 */
@Component
// 1.开启定时任务
@EnableScheduling
// 2.开启多线程
@EnableAsync
@Slf4j
public class MultiThreadScheduleTask {

    /**
     * 推送4D质量控制数据
     */
    //每天早上6点1分调用第三方接口
    @Async
    @Scheduled(cron = "0 1 6 * * ?")
    public void pushQualityControl() throws InterruptedException {
        System.out.println("qualityControl");
    }
    
    /**
     * 定时推送进度曲线数据
     */
    //每天早上4点20分调用第三方接口
    @Async
    @Scheduled(cron = "0 20 4 * * ?")
    public void pushProgress() {
        System.out.println("progress");
    }

    /**
     * 定时车辆定位信息
     *
     * @throws InterruptedException
     */
    //每天早上4点20分调用第三方接口
    @Async
    @Scheduled(cron = "${project.location.cron}")
    public synchronized void pushCarPosition() {
        System.out.println("智慧工地车辆异常");
    }
    
}
